package com.restaurant.application.signin.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;
import java.lang.Integer;
import java.lang.Long;
import java.lang.String;
import java.util.List;

public class SignInData implements PickableBean {
    
    public static final String FN_CUSTOMER = "customer";
    public static final String FN_SIGNINNAME = "signInName";
    public static final String FN_SIGNINTIME = "signInTime";
    public static final String FN_GAINACCUMULATE = "gainAccumulate";
    
    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_CUSTOMER,
             FN_SIGNINNAME,
             FN_SIGNINTIME,
             FN_GAINACCUMULATE);
    
    private UID customer;
    private String signInName;
    private Long signInTime;
    private Integer gainAccumulate;
    
    public SignInData(UID customer, String signInName, Long signInTime, Integer gainAccumulate) {
        setCustomer(customer);
        setSignInName(signInName);
        setSignInTime(signInTime);
        setGainAccumulate(gainAccumulate);
    }
    
    public SignInData() {
    }
    
    public SignInData duplicate() {
        SignInData result = new SignInData();
        result.customer = this.customer;
        result.signInName = this.signInName;
        result.signInTime = this.signInTime;
        result.gainAccumulate = this.gainAccumulate;
        return result;
    }
    
    @Override
    public String toString() {
        return Convert.toJson(this);
    }
    
    public UID getCustomer() {
        return customer;
    }
    
    public void  setCustomer(UID value) {
        this.customer = value;
    }
    
    public SignInData withCustomer(UID value) {
        setCustomer(value);
        return this;
    }
    
    public SignInData withCustomer(UID value, UID defaultValue) {
        setCustomer(value == null ? defaultValue : value);
        return this;
    }
    
    public String getSignInName() {
        return signInName;
    }
    
    public void  setSignInName(String value) {
        this.signInName = value;
    }
    
    public SignInData withSignInName(String value) {
        setSignInName(value);
        return this;
    }
    
    public SignInData withSignInName(String value, String defaultValue) {
        setSignInName(value == null ? defaultValue : value);
        return this;
    }
    
    public Long getSignInTime() {
        return signInTime;
    }
    
    public void  setSignInTime(Long value) {
        this.signInTime = value;
    }
    
    public SignInData withSignInTime(Long value) {
        setSignInTime(value);
        return this;
    }
    
    public SignInData withSignInTime(Long value, Long defaultValue) {
        setSignInTime(value == null ? defaultValue : value);
        return this;
    }
    
    public Integer getGainAccumulate() {
        return gainAccumulate;
    }
    
    public void  setGainAccumulate(Integer value) {
        this.gainAccumulate = value;
    }
    
    public SignInData withGainAccumulate(Integer value) {
        setGainAccumulate(value);
        return this;
    }
    
    public SignInData withGainAccumulate(Integer value, Integer defaultValue) {
        setGainAccumulate(value == null ? defaultValue : value);
        return this;
    }
    
    public Object getValueOf(String name) {
        switch(name) {
        case "customer": return getCustomer();
        case "signInName": return getSignInName();
        case "signInTime": return getSignInTime();
        case "gainAccumulate": return getGainAccumulate();
        }
        return null;
    }
    
    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }
    
    @Override
    public int hashCode() {
        return signature().hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof SignInData)) return false;
        return signature().equals(((SignInData)o).signature());
    }
    
    public String signature() {
        throw new RuntimeException("Bean SignInData has no signature defined, no hash code or equals possible.");
    }
}
